# Acting under Chapter 7: Visuals #
# Author: Johannes Scherzinger #
# Date: 10.02.2021 #

# Package
library(corrgram)



# Figure 1 in Article

# Presence of Authorization of Force / Line plot
# change auth into numeric
UNSC$auth <- as.numeric(UNSC$auth)

ggplot(data = UNSC, aes(x = year.x, y = as.numeric(auth)))+
  stat_summary(geom = "line", fun.y = "mean", color = "skyblue3", size = 2) +
  stat_summary(geom = "linerange", fun.data = "mean_cl_boot", color = "skyblue3", size = .5) + # confidence intervalls per year
  scale_x_continuous(breaks = seq(1990, 2015, 5))+
  scale_y_continuous(labels = scales::percent)+
  labs(title = "Authorization Rate of Outright Force over Time",
       x = "Year",
       y = "Authorization Rate")+
  theme_bw()
#ggsave(file = "Authorization_Rate_Over_Time.png", width = 18, height = 12, units = "cm")




# correlogram of IVs -- used in APPENDIX

# create subset
UNSC_sub <- UNSC[, c("terror.pres", "reg.pres","dem.pres", "r2p.pres", "gen.pres", "crisis.pres", "hr.pres", "auth")]

UNSC_sub$terror.pres <- as.numeric(UNSC_sub$terror.pres)
UNSC_sub$reg.pres <- as.numeric(UNSC_sub$reg.pres)
UNSC_sub$dem.pres <- as.numeric(UNSC_sub$dem.pres)
UNSC_sub$r2p.pres <- as.numeric(UNSC_sub$r2p.pres)
UNSC_sub$gen.pres <- as.numeric(UNSC_sub$gen.pres)
UNSC_sub$crisis.pres <- as.numeric(UNSC_sub$crisis.pres)
UNSC_sub$hr.pres <- as.numeric(UNSC_sub$hr.pres)
UNSC_sub$auth <- as.numeric(UNSC_sub$auth)

# run correlation matrix

corrgram(UNSC_sub, labels = c("Terrorism", "Regional Security", "Democracy", "R2P", "Genocide", "Humanitarian Crisis", "Human Rights", "Authorization"),lower.panel = panel.shade, upper.panel = panel.conf, diag.panel = panel.density, order = TRUE)



